package com.fbs.wowo.userCollect.web;


import com.fbs.wowo.base.BaseController;
import com.fbs.wowo.base.Response;
import com.fbs.wowo.userCollect.entity.UserCollect;
import com.fbs.wowo.userCollect.service.UserCollectService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RequestMapping("userCollect")
@RestController
public class UserCollectController extends BaseController {

    @Resource
    private UserCollectService userCollectService;

    /**
     * 添加收藏
     * @param userCollect
     * @return
     */
    @PostMapping("insertUserCollect")
    public Response insertUserCollect(UserCollect userCollect){
        userCollectService.insertSelective(userCollect);
        return success();
    }

    /**
     * 查询数据详情
     * @param userId
     * @param essayId
     * @return
     */
    @GetMapping("findUserCollect")
    public Response findUserCollect(String userId, String essayId){
        UserCollect userCollect = userCollectService.selectByPrimaryKey(userId, essayId);
        return success(userCollect);
    }

    /**
     * 取消收藏
     * @param userId
     * @param essayId
     * @return
     */
    @PostMapping("deleteUserCollect")
    public Response deleteUserCollect(String userId, String essayId){
        userCollectService.deleteByPrimaryKey(userId,essayId);
        return success();
    }

    /**
     * 我的收藏列表
     */
    @GetMapping("findMyCollect")
    @ResponseBody
    public Response findMyCollect(String userId){
        return success(userCollectService.findCollectListByUserId(userId));
    }


}
